package com.founder.tool.xml;

import java.util.HashMap;
import java.util.Map;

public class EntityMap {
	
	private final static Map<String, Object> entitys = new HashMap<String, Object>();
	
	public EntityMap() {
		
	}
	
	public static Object getEntity(String simpleName) {
		String key = "com.founder.entity." + simpleName;
		Object o = entitys.get(simpleName);
		if (o == null) {
			o = newInstanceObject(key);
			if (o != null) {
				entitys.put(key, o);
			}
		}
		return o;
	}
	
	private static Object newInstanceObject(String className) {
		//System.out.println("className=" + className);
		Object obj = null;
		try {
			Class<?> c = Class.forName(className);
			obj = c.newInstance();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return obj;
	}

}
